package com.ykdl.app.main;

import android.graphics.Color;
import android.os.Bundle;
import android.os.CountDownTimer;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;

import com.androidquery.AQuery;
import com.ykdl.app.R;
import com.ykdl.app.base.BaseActivity;

public class BindPhoneActivity extends BaseActivity {

	private String phone_number, new_phone_number, auth_code;
	private TextView sen_bt;
	private AQuery mAQ;
	private Button enter;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		setTopTitle("绑定新手机", 0, R.drawable.back_bg, new OnClickListener() {
			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				finish();
			}
		}, 0, 0, null, 0);
		SetContentLayout(R.layout.activity_bindphone);
		mAQ = new AQuery(this);
		initView();
	}

	private void initView() {

		sen_bt = (TextView) findViewById(R.id.tv_get_auth_code);
		sen_bt.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				getAuthCode();
			}

		});
		mAQ.id(R.id.enter).clicked(new OnClickListener() {

			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				confirmBind();
			}

		});
	}

	/**
	 * 获取验证码
	 */
	private void getAuthCode() {
		// TODO Auto-generated method stub
		phone_number = mAQ.id(R.id.phone_number).getText().toString().trim();
		new_phone_number = mAQ.id(R.id.new_phone_number).getText().toString()
				.trim();
		auth_code = mAQ.id(R.id.auth_code).getText().toString().trim();
	}

	private void confirmBind() {

	}

	class MyCount extends CountDownTimer {
		public MyCount(long millisInFuture, long countDownInterval) {
			super(millisInFuture, countDownInterval);
		}

		@Override
		public void onFinish() {
			sen_bt.setText("获取验证码");
			sen_bt.setTextColor(Color.parseColor("#454545"));
			sen_bt.setEnabled(true);
		}

		@Override
		public void onTick(long millisUntilFinished) {
			sen_bt.setEnabled(false);
			sen_bt.setTextColor(0xFF9D9D9D);
			sen_bt.setText("请等待(" + millisUntilFinished / 1000 + ")秒");
		}
	}

}
